<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
</head>
<body>
    <form>
        <input type="text" name="username"><br>
        <input type="text" name="password"><br>
        <button type="button" onclick="login()">login</button>
    </form>
    <script type="text/javascript">
        function login() {
            $.ajax({
                url: '/login',
                type: 'post',
                dataType: 'json',
                data: {
                    username: $("input[name='username']").val(),
                    password: $("input[name='password']").val()
                },
                success: function (data) {
                    console.log(data);
                },
                error: function () {
                    console.log("error");
                }
            })
        }
    </script>
</body>
</html>